<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章管理</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f7fa;
            display: flex;
            min-height: 100vh;
        }

        .sidebar {
            width: 240px;
            background-color: #34495e;
            padding: 20px;
            color: white;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .sidebar h2 {
            font-size: 20px;
            margin-bottom: 20px;
            text-align: center;
        }

        .sidebar a {
            display: block;
            margin-bottom: 15px;
            text-decoration: none;
            color: white;
            padding: 12px;
            width: 100%;
            background-color: #2c3e50;
            border-radius: 5px;
            text-align: center;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        .sidebar a:hover {
            background-color: #1abc9c;
        }

        .content {
            flex: 1;
            padding: 40px;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            font-size: 28px;
            color: #2c3e50;
            margin-bottom: 30px;
            border-bottom: 2px solid #ecf0f1;
            padding-bottom: 10px;
        }

        form {
            margin-bottom: 30px;
        }

        label {
            font-size: 16px;
            margin-right: 10px;
            color: #555;
        }

        input[type="text"],
        input[type="datetime-local"],
        select {
            padding: 10px;
            font-size: 14px;
            width: 250px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-right: 10px;
            margin-bottom: 10px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        button[type="submit"] {
            padding: 10px 20px;
            background-color: #2ecc71;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        button[type="submit"]:hover {
            background-color: #27ae60;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 30px;
        }

        table th,
        table td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ecf0f1;
        }

        table th {
            background-color: #f4f6f9;
            color: #7f8c8d;
        }

        table td {
            background-color: #ffffff;
        }

        table tr:hover {
            background-color: #f9f9f9;
        }

        .table-actions button {
            margin-right: 8px;
            padding: 6px 12px;
            font-size: 14px;
            border-radius: 5px;
            cursor: pointer;
            border: none;
            transition: background-color 0.3s ease;
        }

        .table-actions .delete-btn {
            background-color: #e74c3c;
            color: white;
        }

        .table-actions .delete-btn:hover {
            background-color: #c0392b;
        }

        .table-actions .edit-btn {
            background-color: #3498db;
            color: white;
        }

        .table-actions .edit-btn:hover {
            background-color: #2980b9;
        }

        .alert {
            margin-top: 20px;
            padding: 10px;
            background-color: #2ecc71;
            color: white;
            border-radius: 5px;
            text-align: center;
        }

        .button-group {
            margin-bottom: 30px;
        }

        .button-group a button {
            padding: 10px 20px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        .button-group a button:hover {
            background-color: #2980b9;
        }
    </style>
</head>
<body>

<div class="sidebar">
    <h2>团队管理员功能菜单</h2>
    <a href="/admin/achievementmanagement">科研成果管理与发布</a>
    <a href="/admin/usermanagement">用户管理</a>
    <a href="/admin/articlesManagement">文章管理</a>
    <a href="/admin/FeedbacksManagement">反馈管理</a>
    <a href="/admin/teamadmin/teammanagement">团队管理</a>
    <a href="/logout">退出</a>
</div>

<div class="content">
    <h1>文章管理</h1>

    <!-- 搜索框 -->
    <form action="/admin/articlesManagement" method="get">
        <label for="searchKeyword">文章标题关键词：</label>
        <input type="text" id="searchKeyword" name="searchKeyword" value="${searchKeyword}">
        <button type="submit">搜索</button>
    </form>

    <!-- 时间范围筛选 -->
    <form action="/admin/articlesManagement" method="get">
        <label for="startDate">起始日期：</label>
        <input type="datetime-local" id="startDate" name="startDate" value="${startDate}">
        <label for="endDate">结束日期：</label>
        <input type="datetime-local" id="endDate" name="endDate" value="${endDate}">
        <button type="submit">筛选</button>
    </form>

    <!-- 显示所有文章 -->
    <table>
        <thead>
        <tr>
            <th>文章标题</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="article" items="${articles}">
            <tr>
                <td>${article.title}</td>
                <td class="table-actions">
                    <a href="/admin/articles/edit/${article.articleId}">
                        <button type="button" class="edit-btn">编辑</button>
                    </a>
                    <a href="/admin/articles/delete/${article.articleId}">
                        <button type="button" class="delete-btn" onclick="return confirm('确定要删除此文章吗？');">删除</button>
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <!-- 新文章发布按钮 -->
    <div class="button-group">
        <a href="/admin/articles/new">
            <button type="button">新文章发布</button>
        </a>
    </div>
</div>

</body>
</html>
